package com.yuanian.springbootProject.dto;

import java.io.Serializable;

public class ResponseResult implements Serializable {

    private static final long serialVersionUID = 4633451373316892528L;

    // 响应业务状态
    public int status = 200;

    // 响应消息
    public String msg = "操作成功";

    // 响应数据
    public Object data = null;

    public ResponseResult() {
        super();
    }

    public ResponseResult(int status, String msg, Object data) {
        super();
        this.status = status;
        this.msg = msg;
        this.data = data;
    }

    public static ResponseResult bulid(int status, String msg, Object data) {
        return new ResponseResult(status, msg, data);
    }

    public static ResponseResult fail(String msg) {
        return bulid(500, msg, null);
    }

    public static ResponseResult fail() {
        return fail("操作失败");
    }

    public static ResponseResult ok(String msg, Object data) {
        return bulid(200, msg, data);
    }

    public static ResponseResult ok(Object data) {
        return ok("操作成功", data);
    }

    public static ResponseResult ok() {
        return ok("操作成功", null);
    }

    public static ResponseResult ok(String msg) {
        return ok(msg, null);
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "ResponseResult{" +
                "status=" + status +
                ", msg='" + msg + '\'' +
                ", data=" + data +
                '}';
    }
}
